/*
 * Copyright (c) 2023 huipei.x
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.xphsc.kubernetes.core;

import cn.xphsc.kubernetes.core.executor.*;
import cn.xphsc.kubernetes.core.query.*;
import cn.xphsc.kubernetes.core.support.KubernetesConfigBuilder;
import io.kubernetes.client.PodLogs;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.ApiResponse;
import io.kubernetes.client.openapi.apis.*;
import io.kubernetes.client.openapi.models.*;
import org.apache.commons.lang3.StringUtils;

/**
 * {@link }
 * @author <a href="xiongpeih@163.com">huipei.x</a>
 * @description: Kubernetes action template
 * @since 1.0.0
 */
public class KubernetesTemplate extends KubernetesConfigBuilder {

    public KubernetesTemplate() {
        super();

    }
    public ApiClient getClient() {
        return this.initClient();
    }


    public  CoreV1Api core(){
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.CORE);
        CoreV1Api result = (CoreV1Api) executor.execute();
        return result;
    }

    public  AppsV1Api apps(){
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.APPS);
        AppsV1Api result = (AppsV1Api) executor.execute();
        return result;
    }


    public NetworkingV1Api network() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.NETWORKING);
        NetworkingV1Api result = (NetworkingV1Api) executor.execute();
        return result;
    }


    public BatchV1Api batch() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.BATCH);
        BatchV1Api result = (BatchV1Api) executor.execute();
        return result;
    }

    public StorageV1Api storage() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.STORAGE);
        StorageV1Api result = (StorageV1Api) executor.execute();
        return result;
    }

    public PodLogs logs() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.LOGS);
        PodLogs result = (PodLogs) executor.execute();
        return result;
    }

    public VersionApi version() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.VERSION);
        VersionApi result = (VersionApi) executor.execute();
        return result;
    }

    public SchedulingV1Api scheduling() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.SCHEDULING);
        SchedulingV1Api result = (SchedulingV1Api) executor.execute();
        return result;
    }

    public RbacAuthorizationV1Api rbacAuthorization() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.RBAC);
        RbacAuthorizationV1Api result = (RbacAuthorizationV1Api) executor.execute();
        return result;
    }

    public PolicyV1Api policy() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.POLICY);
        PolicyV1Api result = (PolicyV1Api) executor.execute();
        return result;
    }

    public OpenidApi openid() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.OPENID);
        OpenidApi result = (OpenidApi) executor.execute();
        return result;
    }

    public NodeV1Api node() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.NODE);
        NodeV1Api result = (NodeV1Api) executor.execute();
        return result;
    }


    public InternalApiserverV1alpha1Api internalApiserver() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.INTERNAL);
        InternalApiserverV1alpha1Api result = (InternalApiserverV1alpha1Api) executor.execute();
        return result;
    }

    public FlowcontrolApiserverV1beta2Api flowcontrolApiserver() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.FLOWCONTROL);
        FlowcontrolApiserverV1beta2Api result = (FlowcontrolApiserverV1beta2Api) executor.execute();
        return result;
    }

    public EventsV1Api eventsV1Api() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.EVENTS);
        EventsV1Api result = (EventsV1Api) executor.execute();
        return result;
    }

    public DiscoveryV1Api discovery() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.DISCOVERY);
        DiscoveryV1Api result = (DiscoveryV1Api) executor.execute();
        return result;
    }

    public CustomObjectsApi customObjects() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.CUSTOMOBJECTS);
        CustomObjectsApi result = (CustomObjectsApi) executor.execute();
        return result;
    }

    public CoordinationV1Api coordination() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.COORDINATION);
        CoordinationV1Api result = (CoordinationV1Api) executor.execute();
        return result;
    }

    public CertificatesV1Api certificates() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.CERTIAFICATES);
        CertificatesV1Api result = (CertificatesV1Api) executor.execute();
        return result;
    }

    public AutoscalingV2Api autoscaling() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.AUTOSCALING);
        AutoscalingV2Api result = (AutoscalingV2Api) executor.execute();
        return result;
    }

    public AuthorizationV1Api authorization() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.AUTHOROZATION);
        AuthorizationV1Api result = (AuthorizationV1Api) executor.execute();
        return result;
    }


    public AuthenticationV1Api authentication() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.AUTHENTOCATION);
        AuthenticationV1Api result = (AuthenticationV1Api) executor.execute();
        return result;
    }


    public ApiregistrationV1Api apiregistration() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.APIREGISTRATION);
        ApiregistrationV1Api result = (ApiregistrationV1Api) executor.execute();
        return result;
    }


    public ApiextensionsV1Api apiextensions() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.APIEXTENSIONS);
        ApiextensionsV1Api result = (ApiextensionsV1Api) executor.execute();
        return result;
    }


    public AdmissionregistrationV1Api admissionregistration() {
        KubernetesApiExecutor executor = new KubernetesApiExecutor(getClient(), KubernetesApiExecutor.KubernetesApiMode.ADMISS);
        AdmissionregistrationV1Api result = (AdmissionregistrationV1Api) executor.execute();
        return result;
    }

    /**
     * 发布应用 创建Namespace
     */
    public V1Namespace createNamespace(NamespaceBody namespaceBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),namespaceBody, CreateNamespaceExecutor.CreateNamespaceMode.NS);
        V1Namespace result = (V1Namespace) executor.execute();
        return result;
    }
    /**
     *创建Kubernetes中的Secret
     */
    public V1Secret createNamespacedSecret(CreateNamespaceBody namespacedSecretQuery) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),namespacedSecretQuery, CreateNamespaceExecutor.CreateNamespaceMode.NS);
        V1Secret result = (V1Secret) executor.execute();
        return result;
    }
    /**
     *创建Kubernetes中的Deployment
     */
    public V1Deployment createNamespacedDeployment(CreateDeploymentBody createDeploymentBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createDeploymentBody, CreateNamespaceExecutor.CreateNamespaceMode.DEPLY);
        V1Deployment result = (V1Deployment) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的Pod
     */
    public V1Pod createNamespacedPod(NamespacedPodBody namespacedPodQuery) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),namespacedPodQuery, CreateNamespaceExecutor.CreateNamespaceMode.POD);
        V1Pod result = (V1Pod) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的Binding
     *   The parameter body is an V1Binding object
     */
    public V1Binding createNamespacedBinding(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.BINDING);
        V1Binding result = (V1Binding) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的ConfigMap
     *  The parameter body is an V1ConfigMap object
     */
    public V1ConfigMap createNamespacedConfigMap(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.CONFIGMAP);
        V1ConfigMap result = (V1ConfigMap) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的Endpoints
     *  The parameter body is an V1Endpoints object
     */
    public V1Endpoints createNamespacedEndpoints(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.ENDPOINTS);
        V1Endpoints result = (V1Endpoints) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的PodTemplate
     * The parameter body is an V1PodTemplate object
     */
    public V1PodTemplate createNamespacedPodTemplate(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.PODTEMPLATE);
        V1PodTemplate result = (V1PodTemplate) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的Service
     * The parameter body is an V1Service object
     */
    public V1Service createNamespacedService(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.SERVICE);
        V1Service result = (V1Service) executor.execute();
        return result;
    }


    /**
     *创建Kubernetes中的ServiceAccount
     * The parameter body is an V1ServiceAccount object
     */
    public V1ServiceAccount createNamespacedServiceAccount(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.SERVICEACCOUNT);
        V1ServiceAccount result = (V1ServiceAccount) executor.execute();
        return result;
    }


    /**
     *创建Kubernetes中的Node
     * The parameter body is an V1Node object
     */
    public V1Node createNode(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.NODE);
        V1Node result = (V1Node) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的PersistentVolume
     * The parameter body is an V1PersistentVolume object
     */
    public V1PersistentVolume createPersistentVolume(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.PERSISTENTVOLUME);
        V1PersistentVolume result = (V1PersistentVolume) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的DaemonSet
     * The parameter body is an V1DaemonSet object
     */
    public V1DaemonSet createNamespacedDaemonSet(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.DAEMONSET);
        V1DaemonSet result = (V1DaemonSet) executor.execute();
        return result;
    }


    /**
     *创建Kubernetes中的ReplicaSet
     * The parameter body is an V1ReplicaSet object
     */
    public V1ReplicaSet createNamespacedReplicaSet(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.REPLICASET);
        V1ReplicaSet result = (V1ReplicaSet) executor.execute();
        return result;
    }

    /**
     *创建Kubernetes中的StatefulSet
     *  The parameter body is an V1StatefulSet object
     */
    public V1StatefulSet createNamespacedStatefulSet(CreateNamespacedBody createNamespacedPodBody) {
        CreateNamespaceExecutor executor = new CreateNamespaceExecutor(getClient(),createNamespacedPodBody, CreateNamespaceExecutor.CreateNamespaceMode.STATEFULSET);
        V1StatefulSet result = (V1StatefulSet) executor.execute();
        return result;
    }




    /**
     *删除Kubernetes中的Namespace
     *
     */
    public V1Status deleteNamespace(DeleteOptionsBody deleteOptionsBody) { ;
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.NS);
        V1Status  result= (V1Status) executor.execute();
        return result;
    }
    /**
     *删除Kubernetes中的Service
     */
    public V1Service deleteNamespaceService(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.SERVICE);
        V1Service  result= (V1Service) executor.execute();
        return result;
    }
    /**
     *删除Kubernetes中的Deployment
     */
    public V1Status deleteNamespacedDeployment(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.DEPLY);
        V1Status result = (V1Status) executor.execute();
        return result;
    }
    /**
     *删除Kubernetes中的Secret
     */
    public V1Status deleteNamespacedSecret(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.SECRET);
        V1Status result = (V1Status) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的ConfigMap
     */
    public V1Status deleteNamespacedConfigMap(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.CONFIGMAP);
        V1Status result = (V1Status) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的POD
     */
    public V1Pod deleteNamespacedPod(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.POD);
        V1Pod result = (V1Pod) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的Endpoints
     */
    public V1Status deleteNamespacedEndpoints(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.ENDPOINTS);
        V1Status result = (V1Status) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的ServiceAccount
     */
    public V1ServiceAccount deleteNamespacedServiceAccount(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.SERVICEACCOUNT);
        V1ServiceAccount result = (V1ServiceAccount) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的PodTemplate
     */
    public V1PodTemplate deleteNamespacedPodTemplate(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.PODTEMPLATE);
        V1PodTemplate result = (V1PodTemplate) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的Node
     */
    public V1Status deleteNode(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.NODE);
        V1Status result = (V1Status) executor.execute();
        return result;
    }

    /**
     *删除Kubernetes中的PersistentVolume
     */
    public V1Status deletePersistentVolume(DeleteOptionsBody deleteOptionsBody) {
        DeleteNamespaceExecutor executor = new DeleteNamespaceExecutor(getClient(),deleteOptionsBody, DeleteNamespaceExecutor.DeleteOptionMode.PERSISTENTVOLUME);
        V1Status result = (V1Status) executor.execute();
        return result;
    }


    /**
     *修改Kubernetes中的Namespace
     */
    public V1Namespace patchNamespace(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody, PatchNamespaceExecutor.PatchOptionMode.NS);
        V1Namespace result= (V1Namespace) executor.execute();

        return result;
    }

    /**
     *修改Kubernetes中的Service
     */
    public V1Service patchNamespaceService(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody, PatchNamespaceExecutor.PatchOptionMode.SERVICE);
        V1Service result= (V1Service) executor.execute();
        return result;
    }
    /**
     *修改Kubernetes中的Deployment
     */
    public V1Deployment patchNamespacedDeployment(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody, PatchNamespaceExecutor.PatchOptionMode.DEPLY);
        V1Deployment result = (V1Deployment) executor.execute();
        return result;
    }
    /**
     *修改Kubernetes中的Secret
     */
    public V1Secret patchNamespacedSecret(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.SECRET);
        V1Secret result = (V1Secret) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的Endpoints
     */
    public V1Endpoints patchNamespacedEndpoints(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.ENDPOINTS);
        V1Endpoints result = (V1Endpoints) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的Pod
     */
    public V1Pod patchNamespacedPod(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.POD);
        V1Pod result = (V1Pod) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的PodTemplate
     */
    public V1PodTemplate patchNamespacedPodTemplate(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.PODTEMPLATE);
        V1PodTemplate result = (V1PodTemplate) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的ServiceAccount
     */
    public V1ServiceAccount patchNamespacedServiceAccount(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.SERVICEACCOUNT);
        V1ServiceAccount result = (V1ServiceAccount) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的DaemonSet
     */
    public V1DaemonSet patchNamespacedDaemonSet(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.DAEMONSET);
        V1DaemonSet result = (V1DaemonSet) executor.execute();
        return result;
    }


    /**
     *修改Kubernetes中的ReplicaSet
     */
    public V1ReplicaSet patchNamespacedReplicaSet(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.REPLICASET);
        V1ReplicaSet result = (V1ReplicaSet) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的StatefulSet
     */
    public V1StatefulSet patchNamespacedStatefulSet(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.STATEFULSET);
        V1StatefulSet result = (V1StatefulSet) executor.execute();
        return result;
    }


    /**
     *修改Kubernetes中的Node
     */
    public V1Node patchNode(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.NODE);
        V1Node result = (V1Node) executor.execute();
        return result;
    }

    /**
     *修改Kubernetes中的Status
     */
    public V1Namespace patchNamespaceStatus(PatchNamespaceBody patchNamespaceBody) {
        PatchNamespaceExecutor executor = new PatchNamespaceExecutor(getClient(),patchNamespaceBody,  PatchNamespaceExecutor.PatchOptionMode.STATUS);
        V1Namespace result = (V1Namespace) executor.execute();
        return result;
    }

    /**
     *read Kubernetes中的Namespace
     */

    public V1Namespace readNamespace(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.NS);
        V1Namespace result = (V1Namespace) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Service
     */
    public V1Service readNamespacedService(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.SERVICE);
        V1Service result = (V1Service) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Deployment
     */
    public V1Deployment readNamespacedDeployment(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.DEPLY);
        V1Deployment result = (V1Deployment) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Secret
     */
    public V1Secret readNamespacedSecret(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.SECRET);
        V1Secret result = (V1Secret) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的ConfigMap
     */
    public V1ConfigMap readNamespacedConfigMap(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.CONFIGMAP);
        V1ConfigMap result = (V1ConfigMap) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Pod
     */
    public V1Pod readNamespacedPod(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.POD);
        V1Pod result = (V1Pod) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Endpoints
     */
    public V1Endpoints readNamespacedEndpoints(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.ENDPOINTS);
        V1Endpoints result = (V1Endpoints) executor.execute();
        return result;
    }

    /**
     *read Kubernetes中的ServiceAccount
     */
    public V1ServiceAccount readNamespacedServiceAccount(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.SERVICEACCOUNT);
        V1ServiceAccount result = (V1ServiceAccount) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的PodTemplate
     */
    public V1PodTemplate readNamespacedPodTemplate(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.PODTEMPLATE);
        V1PodTemplate result = (V1PodTemplate) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Node
     */
    public V1Node readNode(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.NODE);
        V1Node result = (V1Node) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的PersistentVolume
     */
    public V1PersistentVolume readPersistentVolume(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.PERSISTENTVOLUME);
        V1PersistentVolume result = (V1PersistentVolume) executor.execute();
        return result;
    }
    /**
     *read Kubernetes中的Event
     */
    public CoreV1Event readNamespacedEvent(ReadNamespaceQuery readNamespaceBoby) {
        ReadNamespaceExecutor executor = new ReadNamespaceExecutor(getClient(),readNamespaceBoby,  ReadNamespaceExecutor.ReadOptionMode.EVENT);
        CoreV1Event result = (CoreV1Event) executor.execute();
        return result;
    }

    /**
     *read Kubernetes中的PodLog
     */
    public String readNamespacedPodLog(ReadPodLogQuery readPodLogQuery) {
        PodLogExecutor executor = new PodLogExecutor(getClient(),readPodLogQuery,  PodLogExecutor.PodLogsMode.READ);
        String result = (String) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的Namespace
     */
    public V1Namespace replaceNamespace(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.NS);
        V1Namespace result = (V1Namespace) executor.execute();
        return result;
    }



    /**
     *replace Kubernetes中的Service
     */
    public V1Service replaceNamespacedService(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.SERVICE);
        V1Service result = (V1Service) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的Deployment
     */
    public V1Deployment replaceNamespacedDeployment(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.DEPLY);
        V1Deployment result = (V1Deployment) executor.execute();
        return result;
    }
    /**
     *replace Kubernetes中的Secret
     */
    public V1Secret replaceNamespacedSecret(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.SECRET);
        V1Secret result = (V1Secret) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的ConfigMap
     */
    public V1ConfigMap replaceNamespacedConfigMap(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.CONFIGMAP);
        V1ConfigMap result = (V1ConfigMap) executor.execute();
        return result;
    }


    /**
     *replace Kubernetes中的Pod
     */
    public V1Pod replaceNamespacedPod(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.POD);
        V1Pod result = (V1Pod) executor.execute();
        return result;
    }
    /**
     *replace Kubernetes中的Endpoints
     */
    public V1Endpoints replaceNamespacedEndpoints(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.ENDPOINTS);
        V1Endpoints result = (V1Endpoints) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的ServiceAccount
     */
    public V1ServiceAccount replaceNamespacedServiceAccount(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.SERVICEACCOUNT);
        V1ServiceAccount result = (V1ServiceAccount) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的PodTemplate
     */
    public V1PodTemplate replaceNamespacedPodTemplate(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.PODTEMPLATE);
        V1PodTemplate result = (V1PodTemplate) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的Node
     */
    public V1Node replaceNode(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.NODE);
        V1Node result = (V1Node) executor.execute();
        return result;
    }

    /**
     *replace Kubernetes中的PersistentVolume
     */
    public V1PersistentVolume replacePersistentVolume(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.PERSISTENTVOLUME);
        V1PersistentVolume result = (V1PersistentVolume) executor.execute();
        return result;
    }


    /**
     *replace Kubernetes中的Event
     */
    public CoreV1Event replaceNamespacedEvent(ReplaceNamespaceBody replaceNamespaceBody) {
        ReplaceNamespaceExecutor executor = new ReplaceNamespaceExecutor(getClient(),replaceNamespaceBody,  ReplaceNamespaceExecutor.ReplaceOptionMode.EVENT);
        CoreV1Event result = (CoreV1Event) executor.execute();
        return result;
    }


    /**
     *获取Kubernetes中的所有Namespace的list
     */
    public V1NamespaceList listNamespace(NamespaceQuery namespaceQuery) {
        ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.NS);
        V1NamespaceList result = (V1NamespaceList) executor.execute();
        return result;
    }
    /**
     *获取Kubernetes中的所有Deployment的list
     */
    public V1DeploymentList listNamespacedDeployment(NamespaceQuery namespaceQuery) {
        V1DeploymentList result=null;
        if( StringUtils.isNotBlank(namespaceQuery.namespace())){
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.DEPLY);
            result = (V1DeploymentList) executor.execute();
        }
        else{
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLNSDEPLY);
            result = (V1DeploymentList) executor.execute();
        }

        return result;
    }


    /**
     *获取Kubernetes中的所有Pod的list
     */
    public V1PodList listPod(NamespaceQuery namespaceQuery) {
        V1PodList result=null;
        if(StringUtils.isNotBlank(namespaceQuery.namespace())){
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.POD);
            result = (V1PodList) executor.execute();}
        else{
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLNSPOD);
            result = (V1PodList) executor.execute();
        }
        return result;
    }


    /**
     *获取Kubernetes中的所有Service的list
     */
    public V1ServiceList listService(NamespaceQuery namespaceQuery) {
        ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.SERVICE);
        V1ServiceList result = (V1ServiceList) executor.execute();
        return result;
    }
    /**
     *获取Kubernetes中的所有Endpoint的list
     */
    public V1EndpointsList listEndpoint(NamespaceQuery namespaceQuery) {
        ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ENDPOINTS);
        V1EndpointsList result = (V1EndpointsList) executor.execute();
        return result;
    }

    /**
     *获取Kubernetes中的所有DaemonSet的list
     */
    public V1DaemonSetList listDaemonSet(NamespaceQuery namespaceQuery) {
        V1DaemonSetList result=null;
        if(StringUtils.isNotBlank(namespaceQuery.namespace())) {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(), namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.DS);
            result = (V1DaemonSetList) executor.execute();
        }else{
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(), namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLDS);
            result = (V1DaemonSetList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有IngressClass的list
     */
    public V1IngressList listIngressClass(NetworkQuery networkQuery) {
        NetworkApiExecutor executor = new NetworkApiExecutor(getClient(),networkQuery, NetworkApiExecutor.NetworkTypeMode.LIST, NetworkApiExecutor.NetworkMode.DF);
        V1IngressList  result = (V1IngressList) executor.execute();
        return result;
    }

    /**
     *获取Kubernetes中的所有Ingress的list
     */
    public V1IngressList listIngress(NamespaceQuery namespaceQuery) {
        V1IngressList result=null;
        if(StringUtils.isNotBlank(namespaceQuery.namespace())){
            NetworkApiExecutor executor = new NetworkApiExecutor(getClient(),namespaceQuery, NetworkApiExecutor.NetworkTypeMode.LIST, NetworkApiExecutor.NetworkMode.NS);
            result = (V1IngressList) executor.execute();
        }else{
            NetworkApiExecutor executor = new NetworkApiExecutor(getClient(),namespaceQuery, NetworkApiExecutor.NetworkTypeMode.LIST, NetworkApiExecutor.NetworkMode.ALLNS);
            result = (V1IngressList) executor.execute();
        }
        return result;
    }


    /**
     *获取Kubernetes中的所有sc的list
     */
    public V1StorageClassList listStorageClass(StorageQuery storageQuery) {
        StotageApiExecutor executor = new StotageApiExecutor(getClient(),storageQuery, StotageApiExecutor.StotageTypeMode.LIST, StotageApiExecutor.StotageMode.DF);
        V1StorageClassList result = (V1StorageClassList) executor.execute();
        return result;
    }

    /**
     *用于获取Kubernetes中的所有sc的list
     */
    public ApiResponse<V1StorageClassList> storageClassWithHttpInfo(StorageQuery storageQuery) {
        StotageApiExecutor executor = new StotageApiExecutor(getClient(),storageQuery, StotageApiExecutor.StotageTypeMode.LIST, StotageApiExecutor.StotageMode.HTTPINFO);
        ApiResponse<V1StorageClassList> result = (ApiResponse<V1StorageClassList>) executor.execute();
        return result;
    }


    /**
     *获取Kubernetes中的所有CSISC的list
     */
    public V1CSIStorageCapacityList listCSIStorageCapacity (NamespaceQuery namespaceQuery) {
        V1CSIStorageCapacityList result=null;
        if(StringUtils.isNotBlank(namespaceQuery.namespace())){
            StotageApiExecutor executor = new StotageApiExecutor(getClient(),namespaceQuery, StotageApiExecutor.StotageTypeMode.LIST, StotageApiExecutor.StotageMode.CSISC);
            result = (V1CSIStorageCapacityList) executor.execute();
        }else{
            StotageApiExecutor executor = new StotageApiExecutor(getClient(),namespaceQuery, StotageApiExecutor.StotageTypeMode.LIST, StotageApiExecutor.StotageMode.CSISAllNS);
            result = (V1CSIStorageCapacityList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有pv的list
     */
    public V1PersistentVolumeList listPersistentVolume(NamespaceQuery namespaceQuery) {
        ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.PV);
        V1PersistentVolumeList result = (V1PersistentVolumeList) executor.execute();
        return result;
    }

    /**
     *获取Kubernetes中的所有pvc的list
     */
    public V1PersistentVolumeClaimList listPersistentVolumeClaim(NamespaceQuery namespaceQuery) {
        V1PersistentVolumeClaimList result = null;
        if(StringUtils.isNotBlank(namespaceQuery.namespace())){
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.PVC);
            result = (V1PersistentVolumeClaimList) executor.execute();
        }else{
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLNSPVC);
            result = (V1PersistentVolumeClaimList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有ConfigMap的list
     */
    public V1ConfigMapList   listConfigMap(NamespaceQuery namespaceQuery) {
        V1ConfigMapList result = null;
        if (StringUtils.isNotBlank(namespaceQuery.namespace())) {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.CM);
            result = (V1ConfigMapList) executor.execute();
        } else {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLNSCM);
            result = (V1ConfigMapList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有PodTemplate的list
     */
    public V1PodTemplateList   listNamespacedPodTemplate(NamespaceQuery namespaceQuery) {
        V1PodTemplateList result = null;
        ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.PODTEMPLATE);
        result = (V1PodTemplateList) executor.execute();
        return result;
    }


    /**
     *获取Kubernetes中的所有ServiceAccount的list
     */
    public V1ServiceAccountList   listNamespacedServiceAccount(NamespaceQuery namespaceQuery) {
        V1ServiceAccountList result = null;
        if (StringUtils.isNotBlank(namespaceQuery.namespace())) {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.SA);
            result = (V1ServiceAccountList) executor.execute();
        } else {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLSA);
            result = (V1ServiceAccountList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有ReplicaSet的list
     */
    public V1ReplicaSetList   listNamespacedReplicaSet(NamespaceQuery namespaceQuery) {
        V1ReplicaSetList result = null;
        if (StringUtils.isNotBlank(namespaceQuery.namespace())) {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.REPLICASET);
            result = (V1ReplicaSetList) executor.execute();
        } else {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLREPLICASET);
            result = (V1ReplicaSetList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有StatefulSet的list
     */
    public V1StatefulSetList   listNamespacedStatefulSet(NamespaceQuery namespaceQuery) {
        V1StatefulSetList result = null;
        if (StringUtils.isNotBlank(namespaceQuery.namespace())) {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.STATEFULSET);
            result = (V1StatefulSetList) executor.execute();
        } else {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLSTATEFULSET);
            result = (V1StatefulSetList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有Event的list
     */
    public CoreV1EventList   listNamespacedEvent(NamespaceQuery namespaceQuery) {
        CoreV1EventList result = null;
        if (StringUtils.isNotBlank(namespaceQuery.namespace())) {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.EVENT);
            result = (CoreV1EventList) executor.execute();
        } else {
            ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.ALLEVENT);
            result = (CoreV1EventList) executor.execute();
        }
        return result;
    }

    /**
     *获取Kubernetes中的所有Node的list
     */
    public V1NodeList   listNode(NamespaceQuery namespaceQuery) {
        V1NodeList result = null;
        ListNamespaceExecutor executor = new ListNamespaceExecutor(getClient(),namespaceQuery, ListNamespaceExecutor.ListNamespaceMode.NODE);
        result = (V1NodeList) executor.execute();
        return result;
    }

}


